<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="新增ERP人事还款流程" bodyClass="white-bg"  libs=["prism","bootstrapSelect","ueditor"]/>
<div class="wrapper wrapper-content ibox-content">
    <@form.form id="form-payback-add"  class="form-horizontal">
    <input name="applyUserid" value="${user.id}" class="form-control" type="hidden">
    <input name="serialNumber" value="${serNumber}" class="form-control" type="hidden">
    <div class="form-group">        <label class="col-sm-3 control-label"><@ctx.i18n text = "申请人"/>：
       </label>
        <div class="col-sm-8"><input name="applyUsername" value="${user.name}" class="form-control" type="text" readonly="true" >
        </div>
     </div>
    <div class="form-group">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "受益人"/>：
       </label>
        <div class="col-sm-8"><input name="applyBeneficiaryUsername" value="${user.name}" class="form-control" type="text"  required>
        </div>
     </div>
    <div class="form-group">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "余额"/>：
       </label>
        <div class="col-sm-8"><input name="applyFinancialBankBalance" value="${bpmErpPersonPayback.applyFinancialBankBalance?default('')}" class="form-control" type="number"  required>
        </div>
     </div>
    <div class="form-group">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "输入金额"/>：
       </label>
        <div class="col-sm-8"><input name="applyEnterAmount" value="${bpmErpPersonPayback.applyEnterAmount?default('')}" class="form-control" type="number"  required>
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "选择还款方式"/>：</label>
        <div class="col-sm-8">
            <@form.select name="applyPaybackMethod" dictType="sys_erp_paybackmethod" value="${bpmErpPersonPayback.applyPaybackMethod?default('1')}" required="true" />
        </div>
    </div>
    <div class="form-group bankClass">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "余额"/>：
       </label>
        <div class="col-sm-8"><input name="applyBankBalance" value="${bpmErpPersonPayback.applyBankBalance?default('')}" class="form-control" type="number"  required>
        </div>
     </div>
    <div class="form-group newMoneyClass">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "付款方式"/>：</label>
        <div class="col-sm-8">
            <@form.select name="applyPaymentMethod" dictType="sys_crm_coll_paymethod" value="${bpmErpPersonPayback.applyPaymentMethod?default('')}"  required="true" />
        </div>
    </div>
    <div class="form-group newMoneyClass">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "交易日期"/>：</label>
        <div class="col-sm-8">
            <div class="input-group date">
                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                <input class="form-control time-input" name="applyTransactionDate"  data-type="date"   value="${(bpmErpPersonPayback.applyTransactionDate?string('yyyy-MM-dd'))!}" data-format="yyyy-MM-dd" type="text"  required/>
            </div>
        </div>
    </div>
    <div class="form-group newMoneyClass">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "付款人"/>：
       </label>
        <div class="col-sm-8"><input name="applyPayerName" value="${bpmErpPersonPayback.applyPayerName?default('')}" class="form-control" type="text"  required>
        </div>
     </div>
    <div class="form-group newMoneyClass">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "附件"/>：
       </label>
        <div class="col-sm-8">

            <div class="layui-upload">
                <button type="button" class="btn btn-success btn-sm" id="proofList"><i class="fa fa-upload"></i> 上传附件</button>
                <div class="layui-upload-list layui-upList-minHeight uploadpadding">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th>文件名</th>
                            <th>大小</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="demoproofList">
                        </tbody>
                    </table>
                </div>
                <div class="layui-form-item layui-btn-Center">
                    <div class="layui-input-block text-right">
                        <button type="button" class="layui-btn layui-btn-xs" id="proofListAction">开始上传</button>
                    </div>
                </div>
            </div>

        </div>
     </div>
    <div class="form-group newMoneyClass">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "备注"/>：</label>
        <div class="col-sm-8">
            <textarea name="applyMemo" class="form-control" required>${bpmErpPersonPayback.applyMemo?default("")}</textarea>
        </div>
    </div>
               

 </@form.form>
</div>
<@footer>
    <script type="text/javascript">
        $(function(){
            var applyPaybackMethodValue=$("[name='applyPaybackMethod']").val();
            if(applyPaybackMethodValue=="1"||applyPaybackMethodValue=="2"){
                $(".bankClass").show();
                $(".newMoneyClass").hide();
            }
            else if(applyPaybackMethodValue=="3"){
                $(".bankClass").hide();
                $(".newMoneyClass").show();
            }
        })
        /**
         * 下拉选择框 回调函数案例
         * @param id
         * @param event
         * @param data
         */
        function selectCallback(id, event, data) {
            if (id == "applyPaybackMethod") {
                var applyPaybackMethodValue=data[0].id;
                if(applyPaybackMethodValue=="1"||applyPaybackMethodValue=="2"){
                    $(".bankClass").show();
                    $(".newMoneyClass").hide();
                }
                else if(applyPaybackMethodValue=="3"){
                    $(".bankClass").hide();
                    $(".newMoneyClass").show();
                }
                else {
                    $(".bankClass").hide();
                    $(".newMoneyClass").hide();
                }
            }
        }
        var prefix = baseURL + "erp/payback"
        $("#form-payback-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if (opt.validate.form()) {
                var applyPaybackMethodValue=$("[name='applyPaybackMethod']").val();
                if(applyPaybackMethodValue=="3"){
                    var fileLength=$("#demoproofList").children().length;
                    if(fileLength<=0){
                        opt.warning("请上传附件");
                        return;
                    }
                }

                opt.operate.save(prefix + "/add", $('#form-payback-add').serialize());
            }
        }
        //在插件中使用对象
        $.fn.upfile = function(type) {
            var upfile = new Upfile(this,'',$("input[name='serialNumber']").val(),type);
            layui.use('upload', function() {
                var upload = layui.upload;
                var UplodeIn = upload.render(upfile.options);
                upfile.SetInst(UplodeIn)

            });

        };
        /**
         * 凭证
         */
        $('#proofList').upfile(7);
</script>
</@footer>
</@pageTheme>